package com.cxrj.zhsq.partyMember.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cxrj.zhsq.annotation.SystemControllerLog;
import com.cxrj.zhsq.partyMember.entity.PartyMemberStudy;
import com.cxrj.zhsq.partyMember.service.PartyMemberStudyService;

@Controller
@RequestMapping(value="/partyMemberStudy")
public class PartyMemberStudyController {
	
	@Resource 
	private PartyMemberStudyService partyMemberStudyService;
	
	/**
	 * 分页查询数据
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "selectPage", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> selectPage(HttpServletRequest request,HttpServletResponse response){
		return partyMemberStudyService.selectPage(request,response);
	}
	
	/**
	 * 根据Id查询
	 * @param studyId
	 * @return
	 */
	@RequestMapping("selectById")
	@ResponseBody
	public Map<String, Object> selectById(String studyId, HttpServletRequest request){
		return partyMemberStudyService.selectById(studyId, request);
	}
	
	/**
	 * 插入数据
	 * @param partyMemberStudy
	 * @return
	 */
	@RequestMapping("insertStudy")
	@SystemControllerLog(description = "添加党员学习")
	@ResponseBody
	public Map<String, Object> insertStudy(PartyMemberStudy partyMemberStudy){
		
		return partyMemberStudyService.insertStudy(partyMemberStudy);
	}
	
	/**
	 * 更新数据
	 * @param partyMemberStudy
	 * @return
	 */
	@RequestMapping("updateStudy")
	@ResponseBody
	public Map<String, Object> updateStudy(PartyMemberStudy partyMemberStudy){
		
		return partyMemberStudyService.updateStudy(partyMemberStudy);
	}
	
	/**
	 * 发布或取消发布
	 * @param noticeId
	 * @param noticeImg
	 * @return
	 */
	@RequestMapping(value = "updateReleaseState")
	@ResponseBody
	public Map<String, Object> updateReleaseState(String studyId,String releaseState){
		return partyMemberStudyService.updateReleaseState(studyId,releaseState);
	}
	
	@RequestMapping(value = "deleteStudy")
	@SystemControllerLog(description = "删除党员学习")
	@ResponseBody
	public Map<String, Object> deleteStudy(String studyId,HttpServletRequest request,HttpServletResponse response){
		return partyMemberStudyService.deleteStudy(studyId,request,response);
	}

}
